package com.own.business.level.entity.vo;

import com.own.business.level.entity.po.LevelUserHistory;
import com.own.component.common.base.entity.vo.BaseCreateVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.time.LocalDate;

/**
 * LevelUserHistoryVo
 *
 * @author chenxueli
 * @date 2022-07-25 10:13:00
 */
@ApiModel("用户经验获取流水" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class LevelUserHistoryVo extends BaseCreateVo<LevelUserHistory> {

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("操作前经验")
    private Integer beforeExp;

    @ApiModelProperty("操作后经验")
    private Integer afterExp;

    @ApiModelProperty("获得的经验")
    private Integer exp;

    @ApiModelProperty("经验信息描述")
    private String content;

    @ApiModelProperty("经验类型")
    private String type;

    @ApiModelProperty("操作的日期")
    private LocalDate operateDate;

    @ApiModelProperty("连续次数")
    private Integer consecutive;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public LevelUserHistoryVo(@NonNull LevelUserHistory entity) {
        super(entity);
        this.userId = entity.getFkUserId();
        this.beforeExp = entity.getBeforeExp();
        this.afterExp = entity.getAfterExp();
        this.exp = entity.getExp();
        this.content = entity.getContent();
        this.type = entity.getType();
        this.operateDate = entity.getOperateDate();
        this.consecutive = entity.getConsecutive();
    }

    /**
     * 转po对象
     *
     * @param entity 原
     * @return po对象
     */
    @Override
    public LevelUserHistory toPo(LevelUserHistory entity) {
        if (entity == null) {
            entity = new LevelUserHistory();
        }
        entity.setFkUserId(userId);
        entity.setBeforeExp(beforeExp);
        entity.setAfterExp(afterExp);
        entity.setExp(exp);
        entity.setContent(content);
        entity.setType(type);
        entity.setOperateDate(operateDate);
        entity.setConsecutive(consecutive);
        return super.toPo(entity);
    }
}
